import model from './model'
import API from '../../../API/list'

export default {
  data() {
    return {
      dialogVisible: false,
      model: model(),
      deviceName: '', // 查询设备字段
      deviceList: [],
      API: API,
    }
  },
  computed: {},
  methods: {
    /**
     * 初始化
     */
    init(deviceId) {
      // this.getDeviceName()
      this.model.dataForm.deviceId = deviceId
    },
    clickOrgan() { },
    /**
     * @description:获取关联视频设备
     */
    async getDeviceName() {
      const [content] = await this.API.getDeviceName()
      this.deviceList = content
      this.dialogVisible = true
    },
    deviceChange(id) {
      const obj = [...this.deviceList].find((item) => id === item.id) || {}
      this.model.dataForm.deviceName = obj.deviceName
    },
    sure() {
      this.dialogVisible = false
      this.$emit('sendDevice', this.model.dataForm)
    },
  },
  mounted() { },
}
